package com.cht.commonUtil.infra;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.cht.commonUtil.webInit.SP;
import com.cht.commonUtil.widgets.Widgets;

public class ChkHostConnection extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request,response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding( SP.UIcodeSet );
		response.setContentType("application/text");
		response.setCharacterEncoding( SP.UIcodeSet );
		int res=0;
		
		String url = request.getParameter("ip");
		String usr = request.getParameter("loginId");
		String pwd = request.getParameter("loginPwd");
		
		
		try {
			res = Widgets.chkHostConnection(url, usr, pwd);
		} catch(Exception e) {
			Widgets.errLog(e);
		}
		
		response.getWriter().write( String.valueOf(res) );
	}

}
